## $Id$

export ERL=erl

docdir = ./doc

.PHONY=all
all: beams html

.PHONY=beams
beams:
	cd src && $(MAKE) $@

edocs	= $(addprefix $(docdir)/, overview.edoc)

.PHONY=edoc
edoc:	$(edocs)
	
$(docdir)/%.edoc:	$(docdir)/%.edoc-in
	sed -e 's!%VERSION%!$(APP_VERSION)!' < $< > $@

.PHONY=html
html:	edoc
	$(ERL) -noshell -run edoc_run application "'dvderl'" '"."' \
			'[{sort_functions,false},{private,true},{todo,true}]'
	@cd doc && (for i in `ls *.html`; do sed -e 's!erlang logo!dvd disk!' \
			-e 's!www.erlang.org!dvderl.googlecode.com!' \
			-e 's!erlang.png!dvd-disk.png!' < $$i > t.html; \
			mv t.html $$i; done)


.PHONY=clean
clean:
	cd src && $(MAKE) $@
	-cd doc && rm -f edoc-info index.html modules-frame.html \
			overview-summary.html packages-frame.html \
			stylesheet.css overview.edoc erlang.png
	-cd test && rm -f *.beam
	-cd test/log && rm -rf *.html ct_run.* variables-ct*

.PHONY=check
check:
	cd src && $(MAKE) $@
	dialyzer -c ebin

.PHONY=test
test:	beams
	# run_test -dir test -logdir test/log -pa `pwd`/ebin +W w
	erl -sname ct -pa `pwd`/ebin -s ct_run script_start \
			-s erlang halt -dir test -logdir test/log

